package com.srwl.mytx.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.srwl.mytx.R;

/**
 * Implementation of App Widget functionality.
 */
public class CheckView extends RelativeLayout {

    private TextView tv_count;
    private Context context;

    public CheckView(Context context) {
        super(context);
        init(context);
    }

    public CheckView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    private void init(Context context) {
        LayoutInflater.from(context).inflate(R.layout.custom_check_view_layout, this);
        tv_count = findViewById(R.id.tv_count);
    }

    //显示选中的序号，并设置为蓝色填充白色描边背景
    public void setCount(int count) {
        tv_count.setText(count + "");
        setBackgroundResource(R.drawable.custom_check_view_enable_checked);
    }

    //去掉序号，设置为蓝色圆圈中空背景
    public void removeCount() {
        tv_count.setText("");
    }

    public void setEnableCheck(boolean enableCheck) {
        if (enableCheck) {
            setBackgroundResource(R.drawable.custom_check_view_enable_true);
        } else {
            setBackgroundResource(R.drawable.custom_check_view_enable_false);
        }
    }
}

